/*
 *
 */
package com.ipnc.dss.config;

/**
 * @author dp
 * 
 */
public class Command {
	// IPCamera&Server start
	public static final int IPCAME2SERVER_TCP_GETIP = 10;
	public static final int IPCAME2SERVER_TCP_LOGIN = 11;
	public static final int IPCAME2SERVER_TCP_QUIT_CONFIRM = 12;
	public static final int IPCAME2SERVER_UDP_P2P_LOGIN = 13;
	public static final int IPCAME2SERVER_UDP_P2P_QUIT_CONFIRM = 14;
	public static final int IPCAME2SERVER_UDP_PSP_LOGIN = 15;
	public static final int IPCAME2SERVER_UDP_PSP_QUIT_CONFIRM = 16;
	public static final int IPCAME2SERVER_HEALTH_CHECK_CONFIRM = 17;
	public static final int IPCAME2SERVER_HEALTH_CHECK = 18;
	public static final String COMMAND_IPCAME2SERVER_TCP_GETIP = "@10";
	public static final String COMMAND_IPCAME2SERVER_TCP_LOGIN = "@11";
	public static final String COMMAND_IPCAME2SERVER_TCP_QUIT_CONFIRM = "@12";
	public static final String COMMAND_IPCAME2SERVER_UDP_P2P_LOGIN = "@13";
	public static final String COMMAND_IPCAME2SERVER_UDP_P2P_QUIT_CONFIRM = "@14";
	public static final String COMMAND_IPCAME2SERVER_UDP_PSP_LOGIN = "@15";
	public static final String COMMAND_IPCAME2SERVER_UDP_PSP_QUIT_CONFIRM = "@16";
	public static final String COMMAND_IPCAME2SERVER_HEALTH_CHECK_CONFIRM = "@17";
	public static final String COMMAND_IPCAME2SERVER_HEALTH_CHECK = "@S";

	public static final int SERVER2IPCAME_TCP_GETIP_CONFIRM = 30;
	public static final int SERVER2IPCAME_TCP_LOGIN_CONFIRM = 31;
	public static final int SERVER2IPCAME_TCP_QUIT = 32;
	public static final int SERVER2IPCAME_TCP_P2P_LOGIN_NOTICE = 33;
	public static final int SERVER2IPCAME_TCP_PSP_LOGIN_NOTICE = 34;
	public static final int SERVER2IPCAME_UDP_P2P_LOGIN_CONFIRM = 35;
	public static final int SERVER2IPCAME_UDP_PSP_VEDIO = 36;
	public static final int SERVER2IPCAME_UDP_PSP_AUDIO = 37;
	public static final int SERVER2IPCAME_UDP_PSP_SNAPSHOT = 38;
	public static final int SERVER2IPCAME_UDP_PSP_RECORD = 39;
	public static final int SERVER2IPCAME_UDP_PSP_PTZ = 40;
	public static final int SERVER2IPCAME_UDP_PSP_QUIT = 41;
	public static final int SERVER2IPCAME_HEALTH_CHECK = 42;
	public static final int SERVER2IPCAME_HEALTH_CHECK_CONFIRM = 43;
	public static final String COMMAND_SERVER2IPCAME_TCP_GETIP_CONFIRM = "#30";
	public static final String COMMAND_SERVER2IPCAME_TCP_LOGIN_CONFIRM = "#31";
	public static final String COMMAND_SERVER2IPCAME_TCP_QUIT = "#32";
	public static final String COMMAND_SERVER2IPCAME_TCP_P2P_LOGIN_NOTICE = "#33";
	public static final String COMMAND_SERVER2IPCAME_TCP_PSP_LOGIN_NOTICE = "#34";
	public static final String COMMAND_SERVER2IPCAME_UDP_P2P_LOGIN_CONFIRM = "#35";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_VEDIO = "#36";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_AUDIO = "#37";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_SNAPSHOT = "#38";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_RECORD = "#39";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_PTZ = "#40";
	public static final String COMMAND_SERVER2IPCAME_UDP_PSP_QUIT = "#41";
	public static final String COMMAND_SERVER2IPCAME_HEALTH_CHECK = "#42";
	public static final String COMMAND_SERVER2IPCAME_HEALTH_CHECK_CONFIRM = "#I";
	// IPCamera&Server end

	// Viewer&Server start
	public static final int VIEWER2SERVER_TCP_USER_LOGIN = 50;
	public static final int VIEWER2SERVER_TCP_LOGIN = 51;
	public static final int VIEWER2SERVER_TCP_QUIT = 52;
	public static final int VIEWER2SERVER_UDP_P2P_LOGIN = 53;
	public static final int VIEWER2SERVER_TCP_P2P_DETECT_TIMEOUT = 54;
	public static final int VIEWER2SERVER_UDP_P2P_QUIT = 55;
	public static final int VIEWER2SERVER_UDP_PSP_LOGIN = 56;
	public static final int VIEWER2SERVER_UDP_PSP_VEDIO = 57;
	public static final int VIEWER2SERVER_UDP_PSP_AUDIO = 58;
	public static final int VIEWER2SERVER_UDP_PSP_SNAPSHOT = 59;
	public static final int VIEWER2SERVER_UDP_PSP_RECORD = 60;
	public static final int VIEWER2SERVER_UDP_PSP_PTZ = 61;
	public static final int VIEWER2SERVER_UDP_PSP_QUIT = 62;
	public static final int VIEWER2SERVER_HEALTH_CHECK = 63;
	public static final String COMMAND_VIEWER2SERVER_TCP_USER_LOGIN = "&50";
	public static final String COMMAND_VIEWER2SERVER_TCP_LOGIN = "&51";
	public static final String COMMAND_VIEWER2SERVER_TCP_QUIT = "&52";
	public static final String COMMAND_VIEWER2SERVER_UDP_P2P_LOGIN = "&53";
	public static final String COMMAND_VIEWER2SERVER_TCP_P2P_DETECT_TIMEOUT = "&54";
	public static final String COMMAND_VIEWER2SERVER_UDP_P2P_QUIT = "&55";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_LOGIN = "&56";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_VEDIO = "&57";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_AUDIO = "&58";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_SNAPSHOT = "&59";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_RECORD = "&60";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_PTZ = "&61";
	public static final String COMMAND_VIEWER2SERVER_UDP_PSP_QUIT = "&62";
	public static final String COMMAND_VIEWER2SERVER_HEALTH_CHECK = "#S";

	public static final int SERVER2VIEWER_TCP_USER_LOGIN_CONFIRM = 70;
	public static final int SERVER2VIEWER_TCP_GETIP_CONFIRM = 71;
	public static final int SERVER2VIEWER_TCP_LOGIN_CONFIRM = 72;
	public static final int SERVER2VIEWER_TCP_LOGIN_KICKOFF = 73;
	public static final int SERVER2VIEWER_TCP_QUIT = 74;
	public static final int SERVER2VIEWER_TCP_P2P_LOGIN_NOTICE = 75;
	public static final int SERVER2VIEWER_TCP_PSP_LOGIN_NOTICE = 76;
	public static final int SERVER2VIEWER_UDP_P2P_LOGIN_CONFIRM = 77;
	public static final int SERVER2VIEWER_UDP_P2P_QUIT = 78;
	public static final int SERVER2VIEWER_UDP_PSP_QUIT = 79;
	public static final int SERVER2VIEWER_HEALTH_CHECK_CONFIRM = 80;
	public static final String COMMAND_SERVER2VIEWER_TCP_USER_LOGIN_CONFIRM = "#70";
	public static final String COMMAND_SERVER2VIEWER_TCP_GETIP_CONFIRM = "#71";
	public static final String COMMAND_SERVER2VIEWER_TCP_LOGIN_CONFIRM = "#72";
	public static final String COMMAND_SERVER2VIEWER_TCP_LOGIN_KICKOFF = "#73";
	public static final String COMMAND_SERVER2VIEWER_TCP_QUIT = "#74";
	public static final String COMMAND_SERVER2VIEWER_TCP_P2P_LOGIN_NOTICE = "#75";
	public static final String COMMAND_SERVER2VIEWER_TCP_PSP_LOGIN_NOTICE = "#76";
	public static final String COMMAND_SERVER2VIEWER_UDP_P2P_LOGIN_CONFIRM = "#77";
	public static final String COMMAND_SERVER2VIEWER_UDP_P2P_QUIT = "#78";
	public static final String COMMAND_SERVER2VIEWER_UDP_PSP_QUIT = "#79";
	public static final String COMMAND_SERVER2VIEWER_HEALTH_CHECK_CONFIRM = "#V";
	// Viewer&Server end

	// IPCamera&Viewer start
	public static final int IPCAME2VIEWER_UDP_P2P_DETECT = 85;
	public static final int IPCAME2VIEWER_UDP_P2P_DETECT_CONFIRM = 86;
	public static final String COMMAND_IPCAME2VIEWER_UDP_P2P_DETECT = "@85";
	public static final String COMMAND_IPCAME2VIEWER_UDP_P2P_DETECT_CONFIRM = "@86";

	public static final int VIEWER2IPCAME_UDP_P2P_DETECT = 90;
	public static final int VIEWER2IPCAME_UDP_P2P_VEDIO = 91;
	public static final int VIEWER2IPCAME_UDP_P2P_AUDIO = 92;
	public static final int VIEWER2IPCAME_UDP_P2P_SNAPSHOT = 93;
	public static final int VIEWER2IPCAME_UDP_P2P_RECORD = 94;
	public static final int VIEWER2IPCAME_UDP_P2P_PTZ = 95;
	public static final int VIEWER2IPCAME_UDP_P2P_QUIT = 96;
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_DETECT = "&90";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_VEDIO = "&91";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_AUDIO = "&92";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_SNAPSHOT = "&93";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_RECORD = "&94";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_PTZ = "&95";
	public static final String COMMAND_VIEWER2IPCAME_UDP_P2P_QUIT = "&96";
	// Viewer&IPCamera end

	// Admin start
	public static final int ADMIN_QUERY_ACTIVE_IPCAME = 100;
	public static final int ADMIN_RELOAD_RESOURCE = 101;
	public static final int ADMIN_MODIFY_RESOURCE = 102;
	public static final int ADMIN_CHECK_IPCAME = 103;
	public static final int ADMIN_KICKOFF_IPCAME = 104;
	public static final String COMMAND_ADMIN_QUERY_ACTIVE_IPCAME = "*100";
	public static final String COMMAND_ADMIN_RELOAD_RESOURCE = "*101";
	public static final String COMMAND_ADMIN_MODIFY_RESOURCE = "*102";
	public static final String COMMAND_ADMIN_CHECK_IPCAME = "*103";
	public static final String COMMAND_ADMIN_KICKOFF_IPCAME = "*104";

	// Admin end

	public static Command valueOf(String s) {
		s = s.toUpperCase();
		// IPCAME2SERVER
		if (COMMAND_IPCAME2SERVER_TCP_GETIP.equals(s)) {
			return new Command(IPCAME2SERVER_TCP_GETIP);
		} else if (COMMAND_IPCAME2SERVER_TCP_LOGIN.equals(s)) {
			return new Command(IPCAME2SERVER_TCP_LOGIN);
		} else if (COMMAND_IPCAME2SERVER_TCP_QUIT_CONFIRM.equals(s)) {
			return new Command(IPCAME2SERVER_TCP_QUIT_CONFIRM);
		} else if (COMMAND_IPCAME2SERVER_UDP_P2P_LOGIN.equals(s)) {
			return new Command(IPCAME2SERVER_UDP_P2P_LOGIN);
		} else if (COMMAND_IPCAME2SERVER_UDP_P2P_QUIT_CONFIRM.equals(s)) {
			return new Command(IPCAME2SERVER_UDP_P2P_QUIT_CONFIRM);
		} else if (COMMAND_IPCAME2SERVER_UDP_PSP_LOGIN.equals(s)) {
			return new Command(IPCAME2SERVER_UDP_PSP_LOGIN);
		} else if (COMMAND_IPCAME2SERVER_UDP_PSP_QUIT_CONFIRM.equals(s)) {
			return new Command(IPCAME2SERVER_UDP_PSP_QUIT_CONFIRM);
		} else if (COMMAND_IPCAME2SERVER_HEALTH_CHECK.equals(s)) {
			return new Command(IPCAME2SERVER_HEALTH_CHECK);
		} else if (COMMAND_IPCAME2SERVER_HEALTH_CHECK_CONFIRM.equals(s)) {
			return new Command(IPCAME2SERVER_HEALTH_CHECK_CONFIRM);
		}
		// SERVER2IPCAME
		else if (COMMAND_SERVER2IPCAME_TCP_GETIP_CONFIRM.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_GETIP_CONFIRM);
		} else if (COMMAND_SERVER2IPCAME_TCP_LOGIN_CONFIRM.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_LOGIN_CONFIRM);
		} else if (COMMAND_SERVER2IPCAME_TCP_QUIT.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_QUIT);
		} else if (COMMAND_SERVER2IPCAME_TCP_QUIT.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_QUIT);
		} else if (COMMAND_SERVER2IPCAME_TCP_P2P_LOGIN_NOTICE.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_P2P_LOGIN_NOTICE);
		} else if (COMMAND_SERVER2IPCAME_TCP_PSP_LOGIN_NOTICE.equals(s)) {
			return new Command(SERVER2IPCAME_TCP_PSP_LOGIN_NOTICE);
		} else if (COMMAND_SERVER2IPCAME_UDP_P2P_LOGIN_CONFIRM.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_P2P_LOGIN_CONFIRM);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_VEDIO.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_VEDIO);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_AUDIO.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_AUDIO);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_SNAPSHOT.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_SNAPSHOT);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_RECORD.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_RECORD);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_PTZ.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_PTZ);
		} else if (COMMAND_SERVER2IPCAME_UDP_PSP_QUIT.equals(s)) {
			return new Command(SERVER2IPCAME_UDP_PSP_QUIT);
		} else if (COMMAND_SERVER2IPCAME_HEALTH_CHECK.equals(s)) {
			return new Command(SERVER2IPCAME_HEALTH_CHECK);
		} else if (COMMAND_SERVER2IPCAME_HEALTH_CHECK_CONFIRM.equals(s)) {
			return new Command(SERVER2IPCAME_HEALTH_CHECK_CONFIRM);
		}
		// VIEWER2SERVER
		else if (COMMAND_VIEWER2SERVER_TCP_USER_LOGIN.equals(s)) {
			return new Command(VIEWER2SERVER_TCP_USER_LOGIN);
		} else if (COMMAND_VIEWER2SERVER_TCP_LOGIN.equals(s)) {
			return new Command(VIEWER2SERVER_TCP_LOGIN);
		} else if (COMMAND_VIEWER2SERVER_TCP_QUIT.equals(s)) {
			return new Command(VIEWER2SERVER_TCP_QUIT);
		} else if (COMMAND_VIEWER2SERVER_UDP_P2P_LOGIN.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_P2P_LOGIN);
		} else if (COMMAND_VIEWER2SERVER_TCP_P2P_DETECT_TIMEOUT.equals(s)) {
			return new Command(VIEWER2SERVER_TCP_P2P_DETECT_TIMEOUT);
		} else if (COMMAND_VIEWER2SERVER_UDP_P2P_QUIT.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_P2P_QUIT);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_LOGIN.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_LOGIN);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_VEDIO.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_VEDIO);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_AUDIO.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_AUDIO);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_SNAPSHOT.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_SNAPSHOT);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_RECORD.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_RECORD);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_PTZ.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_PTZ);
		} else if (COMMAND_VIEWER2SERVER_UDP_PSP_QUIT.equals(s)) {
			return new Command(VIEWER2SERVER_UDP_PSP_QUIT);
		} else if (COMMAND_VIEWER2SERVER_HEALTH_CHECK.equals(s)) {
			return new Command(VIEWER2SERVER_HEALTH_CHECK);
		}
		// SERVER2VIEWER
		else if (COMMAND_SERVER2VIEWER_TCP_USER_LOGIN_CONFIRM.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_USER_LOGIN_CONFIRM);
		} else if (COMMAND_SERVER2VIEWER_TCP_GETIP_CONFIRM.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_GETIP_CONFIRM);
		} else if (COMMAND_SERVER2VIEWER_TCP_LOGIN_CONFIRM.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_LOGIN_CONFIRM);
		} else if (COMMAND_SERVER2VIEWER_TCP_LOGIN_KICKOFF.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_LOGIN_KICKOFF);
		} else if (COMMAND_SERVER2VIEWER_TCP_QUIT.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_QUIT);
		} else if (COMMAND_SERVER2VIEWER_TCP_P2P_LOGIN_NOTICE.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_P2P_LOGIN_NOTICE);
		} else if (COMMAND_SERVER2VIEWER_UDP_P2P_LOGIN_CONFIRM.equals(s)) {
			return new Command(SERVER2VIEWER_UDP_P2P_LOGIN_CONFIRM);
		} else if (COMMAND_SERVER2VIEWER_UDP_P2P_QUIT.equals(s)) {
			return new Command(SERVER2VIEWER_UDP_P2P_QUIT);
		} else if (COMMAND_SERVER2VIEWER_TCP_PSP_LOGIN_NOTICE.equals(s)) {
			return new Command(SERVER2VIEWER_TCP_PSP_LOGIN_NOTICE);
		} else if (COMMAND_SERVER2VIEWER_UDP_PSP_QUIT.equals(s)) {
			return new Command(SERVER2VIEWER_UDP_PSP_QUIT);
		} else if (COMMAND_SERVER2VIEWER_HEALTH_CHECK_CONFIRM.equals(s)) {
			return new Command(SERVER2VIEWER_HEALTH_CHECK_CONFIRM);
		}
		// IPCAME2VIEWER
		else if (COMMAND_IPCAME2VIEWER_UDP_P2P_DETECT.equals(s)) {
			return new Command(IPCAME2VIEWER_UDP_P2P_DETECT);
		} else if (COMMAND_IPCAME2VIEWER_UDP_P2P_DETECT_CONFIRM.equals(s)) {
			return new Command(IPCAME2VIEWER_UDP_P2P_DETECT_CONFIRM);
		}
		// VIEWER2IPCAME
		else if (COMMAND_VIEWER2IPCAME_UDP_P2P_DETECT.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_DETECT);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_VEDIO.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_VEDIO);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_AUDIO.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_AUDIO);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_SNAPSHOT.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_SNAPSHOT);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_RECORD.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_RECORD);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_PTZ.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_PTZ);
		} else if (COMMAND_VIEWER2IPCAME_UDP_P2P_QUIT.equals(s)) {
			return new Command(VIEWER2IPCAME_UDP_P2P_QUIT);
		}
		// ADMIN
		else if (COMMAND_ADMIN_QUERY_ACTIVE_IPCAME.equals(s)) {
			return new Command(ADMIN_QUERY_ACTIVE_IPCAME);
		} else if (COMMAND_ADMIN_RELOAD_RESOURCE.equals(s)) {
			return new Command(ADMIN_RELOAD_RESOURCE);
		} else if (COMMAND_ADMIN_MODIFY_RESOURCE.equals(s)) {
			return new Command(ADMIN_MODIFY_RESOURCE);
		} else if (COMMAND_ADMIN_CHECK_IPCAME.equals(s)) {
			return new Command(ADMIN_CHECK_IPCAME);
		} else if (COMMAND_ADMIN_KICKOFF_IPCAME.equals(s)) {
			return new Command(ADMIN_KICKOFF_IPCAME);
		}
		
		throw new IllegalArgumentException("IPNC Server: Unrecognized command "
				+ s);
	}

	private final int num;

	private Command(int num) {
		this.num = num;
	}

	public int toInt() {
		return num;
	}
}
